/*
 * MouseHandler.java
 *
 * Created on October 9, 2007, 12:12 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package pd1;

import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JLabel;

/**
 *
 * @author Pizzol
 */
public class MouseHandler implements  MouseMotionListener, MouseListener {
    
    private JLabel figura = null;
    private PixInImage pix = null;
    private int w = 0;
    private int h = 0;
    
    /** Creates a new instance of MouseHandler */
    public MouseHandler(JLabel picture, int w, int h) {
        this.figura = picture;
        pix = null/* new PixInImage()*/;
        pix.setVisible(true);
    }
    
    public void mouseDragged(MouseEvent e) {
    }
    
    public void mouseMoved(MouseEvent e) {
        
        try {
            Point p = figura.getMousePosition();
            p.setLocation(p.getX()-w+5, p.getY()-h+16);
            pix.setPoint2((int)p.getX(), (int)p.getY());
        }catch(Exception et) {
            et.printStackTrace();
        }
        
        
    }
    
    public void mouseClicked(MouseEvent e) {
    }
    
    public void mousePressed(MouseEvent e) {
        Point p = figura.getMousePosition();
        p.setLocation(p.getX()-w+5, p.getY()-h+16);
        pix.setPoint((int)p.getX(), (int)p.getY());
        
    }
    
    public void mouseReleased(MouseEvent e) {
        pix.setVisible(true);
    }
    
    public void mouseEntered(MouseEvent e) {
    }
    
    public void mouseExited(MouseEvent e) {
    }
    

}
